<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <link rel="icon" type="image/x-icon" href="/signin/favicon.ico"/>
    <title>登录</title>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        body {
            font: 12px/1.5 "Microsoft YaHei", tahoma, arial, 'Hiragino Sans GB', '\5b8b\4f53', sans-serif;
        }

        ul, li, i {
            list-style: none;
            font-style: normal
        }

        form {
            width: 500px;
            margin: 30px auto;
            color: #6C6C6C;
        }

        p {
            height: 30px;
            line-height: 30px;
            margin-bottom: 26px;
            position: relative;
        }

        label {
            float: left;
            width: 100px;
            text-align: right;
            font-size: 14px;
        }

        span {
            font-size: 12px;
        }

        #sub {
            list-style: none;
            background-color: #2d8cf0;
            border: 1px solid #2d8cf0;
            color: #fff !important;
            margin-top: 0px;
            line-height: 36px;
            height: 36px;
            width: 120px;
            display: inline-block;
            text-align: center;
            text-decoration: none;
            vertical-align: middle;
            cursor: pointer;
            font-size: 14px;
            font-weight: 700;
            border-radius: 2px;
            padding: 0 20px;
            margin-left: 80px;
            margin-top: 10px;
        }

        #home {
            list-style: none;
            background-color: #2d8cf0;
            border: 1px solid #2d8cf0;
            color: #fff !important;
            margin-top: 0px;
            line-height: 36px;
            height: 36px;
            width: 120px;
            display: inline-block;
            text-align: center;
            text-decoration: none;
            vertical-align: middle;
            cursor: pointer;
            font-size: 14px;
            font-weight: 700;
            border-radius: 2px;
            padding: 0 20px;
            margin-left: 50px;
            margin-top: 10px;
        }

        p input {
            float: left;
            font-size: 12px;
            color: #6C6C6C;
            vertical-align: middle;
            border: 1px solid #ddd;
            height: 24px;
            width: 300px;
            line-height: 24px;
            padding: 3px 10px;
            margin-right: 8px;
        }

        #yzm, #imgCode {
            width: 88px;
        }

        .getYzm {
            background: #FFF1E8;
            border: 1px solid #FF751A;
            height: 100%;
            white-space: nowrap;
            padding: 0 4px;
            min-width: 188px;
            color: #FF6A00;
            border-radius: 3px;
        }

        p span {
            display: none;
            font-size: 14px;
            color: #ff5243;
            position: absolute;
            top: 28px;
            left: 100px;
        }

        span img {
            width: 16px;
            margin-bottom: -3px;
        }

        span b {
            font-weight: 400;
            font-size: 12px;
        }

        p.err input {
            border-color: #ff5243;
        }

        p.err span {
            display: block;
        }

        p .success {
            color: #b7b7b7;
        }

        #kaptcha {
            display: block;
        }

        .step {
            width: 800px;
            margin: 0 auto;
            margin-top: 60px;
            position: relative;
        }

        .step:after {
            display: block;
            content: '.';
            height: 0;
            clear: both;
            visibility: hidden;
        }

        .step li {
            float: left;
            width: 33%;
            height: 54px;
            position: relative;
        }

        .ul-line {
            height: 3px;
            background: #b9b9b9;
            display: block;
            margin-top: 14px;
            line-height: 1;
            overflow: hidden;
        }

        .ul-icon {
            height: 50px;
            position: absolute;
            top: 0;
            width: 150px;
            text-align: center;
            left: -25px;
        }

        .iconfont {
            display: block;
            width: 30px;
            height: 30px;
            margin: 0;
            line-height: 30px;
            background: #fff;
            padding: 0 10px;
            position: absolute;
            top: 0;
            left: 0;
            text-shadow: 1px 1px 2px #fff, 0 0 0 #ccc, 1px 1px 2px #fff;
            background: #FFFFFF;
        }

        .iconfont:before {
            display: block;
            content: '';
            position: absolute;
            width: 30px;
            height: 30px;
            background: #b7b7b7;
            transform: rotate(45deg);
            border-radius: 6px;
        }

        .ul-number {
            font-size: 14px;
            line-height: 14px;
            position: absolute;
            top: 7px;
            left: 0;
            padding: 0 20px;
            font-weight: 700;
            color: #fff;
        }

        .step span {
            display: block;
            height: 30px;
            line-height: 30px;
            position: relative;
            text-shadow: 0 1px 0 #fff;
            top: 34px;
            left: -50px;
            color: #b7b7b7;
            font-size: 14px;
        }

        .step .step-end {
            position: absolute;
            top: 0;
            right: -140px;
            width: 150px;
            zoom: 1;
        }

        .step .active .iconfont:before {
            background: #00C1DE;
        }

        .step .active span {
            color: #00C1DE;
        }

        .div-bar {
            background: #2d8cf0;
            width: 100%;
            height: 50px;
            text-align: center;
            line-height: 50px;
            font-size: 20px;

        }
    </style>
</head>
<body>
<div class="div-bar"><font color="white">忘记密码</font></div>
<ul class="step">
    <li class="active">
        <div class="ul-line"></div>
        <div class="ul-icon">
            <i class="iconfont"></i>
            <i class="ul-number">1</i>
            <span>验证身份</span>
        </div>
    </li>
    <li>
        <div class="ul-line"></div>
        <div class="ul-icon">
            <i class="iconfont"></i>
            <i class="ul-number">2</i>
            <span>发送邮件</span>
        </div>
    </li>
    <li>
        <div class="ul-line"></div>
        <div class="ul-icon">
            <i class="iconfont"></i>
            <i class="ul-number">3</i>
            <span>找回密码</span>
        </div>
    </li>
    <li class="step-end">
        <div class="ul-icon">
            <i class="iconfont"></i>
            <i class="ul-number">√</i>
            <span>完成</span>
        </div>
    </li>
</ul>
<form>
    <p class="user">
        <label for="user">用户：</label>
        <input type="text" name="user"/>
        <span><img src="/signin/image/err.png"/><b>用户不存在</b></span>
    </p>
    <p class="email">
        <label for="email">邮箱：</label>
        <input type="text" name="email"/>
        <span><img src="/signin/image/err.png"/><b>邮箱格式不正确</b></span>
    </p>
    <p class="imgcode">
        <label for="yzm">验证码：</label>
        <input type="text" id="imgCode"/>
        <img src="/signin/kaptcha" id='kaptcha'/>
        <span><img src="/signin/image/err.png"/><b>验证码错误</b></span>
    </p>
    <p><input id="sub" type="button" value="下一步"/><label> </label><input id="home" type="button" value="返回"/></p>
</form>
<script src="/signin/js/jQuery.3.3.1.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    $('#sub').click(function (e) {
        e.preventDefault();
        var user = $('input[name=user]').val();
        var email = $('input[name=email]').val();
        var imgCode = $('#imgCode').val();
        $('p').removeClass('err')
        $('.success').css('display', 'none')
        if (user == '') {
            err('.user', '请输入用户名')
        } else if (!filter.test(email)) {
            $('.email').addClass('err')
        } else if (imgCode == '') {
            err('.imgcode', '请输入图形验证码')
        } else {
            var mail = {
                email: email,
                imageCode: imgCode,
                account: user
            }
            $.post("/signin/user/validateUserInfo", mail, function (result) {
                console.log(result.code)
                if (result.code == 200) {
                    var admin = {
                        'email': email,
                        'user': user
                    }
                    admin = JSON.stringify(admin);
                    localStorage.setItem('admin', admin)
                    window.location.href = '/signin/user/password/sendMail';
                } else if (result.code == 401 && result.message == '图形验证码错误') {
                    err('.imgcode', '图形验证码错误')
                    $('#kaptcha').trigger("click");
                } else if (result.code == 401 && result.message == '用户名或邮箱不存在') {
                    err('.user', '用户名或邮箱不存在')
                }
            });
        }
    })
    $('#home').click(function () {
        $.post("/signin/user/gohome", null, function (result) {
            window.location.href = result.result;
        });

    })
    $("#kaptcha").click(function () {
        $("#kaptcha").attr('src', '/signin/kaptcha?' + Math.floor(Math.random() * 100)).fadeIn();
    });

    function err(name, txt) {
        $(name).addClass('err');
        $(name).find('b').html(txt)
    }

    var countdown = 60;

    function settime(e) {
        if (countdown == 0) {
            $('.success').css('display', 'none');
            e.attr('disabled', false);
            e.val("免费获取验证码");
            countdown = 60;
            return;
        } else {
            e.attr('disabled', true);
            e.val("重新发送(" + countdown + "s)");
            countdown--;
            setTimeout(function () {
                settime(e)
            }, 1000)
        }
    }
</script>
</body>
</html>
